home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / AppMaker 2.0b3 / Demo AppMaker 1.5 / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpC_104_MainMenu < prev    next >
Encoding:
Text File  |  1992-04-08  |  2.7 KB  |  143 lines

  1. /* %filename% */
  2. /* Created %date% %time% by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <TextEdit.h>
  12. #include "Globals.h"
  13. #include "ResourceDefs.h"
  14. #include "Miscellany.h"
  15. %for each menu gen include%
  16.  
  17. #include <Desk.h>
  18. #include <ToolUtils.h>
  19. #include "MainMenu.h"
  20.  
  21. %If lang = MPW%
  22.     #pragma segment MainMenu 
  23.  
  24. %end if%
  25.  
  26. static void Enable            (short            itemNr,
  27.                              Boolean        enabled);
  28. static void EnableTitle        (MenuHandle        menu,
  29.                              Boolean        enabled);
  30. static void DoApple         (short             itemNr);
  31.  
  32. /*----------*/
  33. void InitTitles (void)
  34. {
  35.     %for each menu gen initTitles%
  36.  
  37. } /*InitTitles*/
  38.  
  39. /*----------*/
  40. void LoadMenus (void)
  41. {
  42.     %for each menu gen get%
  43.  
  44.     %for each menu gen insert%
  45.  
  46.     DrawMenuBar ();
  47. } /*LoadMenus*/
  48.  
  49. %for each menu gen doApple%
  50. /*----------*/
  51. void DoMenu (long        menuChoice)
  52. {
  53.     short            menuID;
  54.     short            itemNr;
  55.  
  56.     menuID = HiWord (menuChoice);
  57.     itemNr = LoWord (menuChoice);
  58.     
  59.     switch (menuID) {
  60.     case 0:
  61.             /*Do nothing*/;
  62.         break;
  63.     %for each menu gen dispatch%
  64.  
  65.     } /*switch*/
  66.  
  67.     HiliteMenu (0);
  68. } /*DoMenu*/
  69.  
  70. /*----------*/
  71. MenuHandle        menu;
  72. Boolean            menuBarChanged;
  73.  
  74. /*----------*/
  75. static void Enable    (short        itemNr, 
  76.                      Boolean    enabled)
  77. {
  78.     if (enabled) {
  79.         EnableItem  (menu, itemNr);
  80.     } else {
  81.         DisableItem (menu, itemNr);
  82.     }
  83. } /*Enable*/
  84.  
  85. /*----------*/
  86. static void EnableTitle    (MenuHandle        menu,
  87.                          Boolean        enabled)
  88. {
  89.     if (enabled != ((**menu).enableFlags & 1)) {
  90.         menuBarChanged = true;
  91.     }
  92.     if (enabled) {
  93.         EnableItem  (menu, 0);
  94.     } else {
  95.         DisableItem (menu, 0);
  96.     }
  97. } /*EnableTitle*/
  98.  
  99. /*----------*/
  100. void UpdateMenus (void)
  101. {
  102.     WindowPeek        frontPeek;
  103.     Boolean            isFront;            /*is there a front window?*/
  104.     Boolean            isCur;                /*is there a current window?*/
  105.     Boolean            isDirty;            /*is it dirty?*/
  106.     Boolean            hasFile;            /*does it have a file?*/
  107.     Boolean            isSelected;            /*is anything selected?*/
  108.     Boolean            isDesk;                /*is the front window a desk acc?*/
  109.     Boolean            isText;                /*is there a current text field?*/
  110.     Boolean            isScrap;            /*is there any scrap?*/
  111.     menuBarChanged = false;
  112.  
  113.     isFront        = (FrontWindow () != nil);
  114.     isCur        = (curWindow != nil);
  115.     isDirty     = false;
  116.     hasFile     = false;
  117.     isSelected    = false;
  118.     if (isCur) {
  119.         isDirty        =  cur->dirty;
  120.         hasFile        = (cur->fileNum != 0);
  121.     }
  122.  
  123.     isDesk = false;
  124.     if (isFront) {
  125.         frontPeek    = (WindowPeek) FrontWindow ();
  126.         isDesk        = (frontPeek->windowKind < 0);
  127.     }
  128.     isText        = isCur && (cur->text != nil);
  129.     isScrap        = false;
  130.     if (isText) {
  131.         isSelected    = ((**(cur->text)).selStart != (**(cur->text)).selEnd);
  132.         isScrap        = (TEGetScrapLen () > 0);
  133.     }
  134.  
  135.     %for each menu gen enable%
  136.  
  137.     if (menuBarChanged) {
  138.         DrawMenuBar ();
  139.     }
  140. } /*UpdateMenus*/
  141.  
  142. /* MainMenu */
  143.